package org.example.chapter10.controller;

import org.example.chapter10.entity.User;
import org.example.chapter10.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author CoderXshuai
 * @date 2020/9/30/0030 11:01
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/insert")
    @ResponseBody
    public User insertUser(@RequestBody User user) {
        userService.insertUser(user);
        return user;
    }

    @GetMapping("/{id}")
    @ResponseBody
    public User getUser(@PathVariable("id") Long id) {
        return userService.getUser(id);
    }

}
